import matplotlib.pyplot as plt

# 创建事件次数的条形图
fig, ax = plt.subplots()
for event_type, processes in event_counter.items():
    process_names = list(processes.keys())
    counts = list(processes.values())
    ax.bar(process_names, counts, label=event_type)

ax.set_xlabel('进程名称')
ax.set_ylabel('事件次数')
ax.set_title('事件次数统计')
ax.legend()

plt.xticks(rotation=90)
plt.tight_layout()
plt.show()

# 创建事件时间间隔的折线图
fig, ax = plt.subplots()
for event_type, times in timestamps.items():
    if len(times) > 1:
        intervals = [t1 - t0 for t0, t1 in zip(times, times[1:])]
        ax.plot(intervals, label=event_type)

ax.set_xlabel('时间')
ax.set_ylabel('时间间隔（秒）')
ax.set_title('事件时间间隔统计')
ax.legend()

plt.tight_layout()
plt.show()